Organize Twitter in Scrapbox
Twitter The discussion above is hard to read, so I'd like to summarize it in Scrapbox. We want to make that process of putting it together easy.
I tried a bot to put it all together, but it didn't work to my satisfaction.
Is it better to run JS in the browser than to do it via API?
How to do it from the Togetter edit screen
Sorting and removal can be done in a natural UI.
code:js
get_name = (tweet) => tweet.querySelector(".user_link .status_name").innerText.substring(1);
remove_mention = (text) => text.replace(/@\w+\s+/g, "");
concat_line = (text) => text.replace(/\n+/g, " ");
text = Array.from(tweets).map(x=> {
name = get_name(x)
body = x.querySelector(".tweet").innerText;
body = remove_mention(body)
//body = concat_line(body)
return >[${name} ${url}]: ${body};
}).join("\n\n")
document.querySelector(".title_input").value = text
-----
From Togetter
code:js
tweets = document.getElementsByClassName("list_box type_tweet")
code:js
get_name = (tweet) => tweet.querySelector(".user_link .status_name").innerText.substring(1)
// e.g. getName(x) => "nishio"
code:js
count = {}
tweets.forEach(x=>{
name = get_name(x);
})
// e.g. {nishio: 26, YukiMihashi: 8, maltonn_: 1, ukkaripon: 3, teramotodaiki: 2, …}
code:js
name_or_icon = (name) => name in use_icon ? [${name}.icon] : name;
// name_or_icon("nishio")
// "nishio.icon"
// name_or_icon("foo")
// "foo"
code:js
text = Array.from(tweets).map(x=> {
name = name_or_icon(getName(x))
body = x.querySelector(".tweet").innerText;
return ${name}\n${body};
}).join("\n\n")
code:js
navigator.clipboard.writeText(text)
// on Devtool: Uncaught (in promise) DOMException: Document is not focused.
matome
code:js
tweets = document.getElementsByClassName("list_box type_tweet")
get_name = (tweet) => tweet.querySelector(".user_link .status_name").innerText.substring(1)
count = {}
tweets.forEach(x=>{
name = get_name(x);
})
code:js
tweets = document.getElementsByClassName("list_box type_tweet")
get_name = (tweet) => tweet.querySelector(".user_link .status_name").innerText.substring(1)
use_icon = {nishio:0, YukiMihashi:0, ukkaripon:0, teramotodaiki:0}
name_or_icon = (name) => name in use_icon ? [${name}.icon] : name;
text = Array.from(tweets).map(x=> {
name = name_or_icon(get_name(x))
body = x.querySelector(".tweet").innerText;
return ${name}\n${body};
}).join("\n\n")
document.write(<textarea>${text}</textarea>)
I heard that iconic notation is not available in Helpfeel, so I guess I'll just have to do it this way for now.
code:js
tweets = document.getElementsByClassName("list_box type_tweet")
get_name = (tweet) => tweet.querySelector(".user_link .status_name").innerText.substring(1)
use_icon = {nishio:0, YukiMihashi:0, ukkaripon:0, teramotodaiki:0, kyasbal_1994: 3, mitoujr: 2, yasulab: 1}
name_or_icon = (name) => name in use_icon ? [${name}] : name;
text = Array.from(tweets).map(x=> {
name = name_or_icon(get_name(x))
body = x.querySelector(".tweet").innerText;
return ${name}:\n${body};
}).join("\n\n")
document.write(<textarea>${text}</textarea>)
---
This page is auto-translated from /nishio/TwitterをScrapboxにまとめる. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.